'use strict';

const Controller = require('egg').Controller;

class BannerController extends Controller {
  async index() {
    const {ctx} = this
    var db = this.app.mongodb
    var res = await db.collection("article").find().toArray()
    var url = ctx.origin+"/public"
    res.forEach(item=>{
        item.imgSrc = url + item.imgSrc
        item.avatar = url + item.avatar
        item.headImgSrc = url + item.headImgSrc
    })
    ctx.body = {
        code:200,
        res
    }
  }
}

module.exports = BannerController;
